/**
 * XL-Payment 支付适配器索引
 * 整合所有支付方式的适配器
 */
import WechatAdapter from './wechat';
import AlipayAdapter from './alipay';
import VirtualAdapter from './virtual';
import UnionpayAdapter from './unionpay';

// 适配器映射
const adapters = {
  wechat: WechatAdapter,
  alipay: AlipayAdapter,
  virtual: VirtualAdapter,
  unionpay: UnionpayAdapter
};

/**
 * 获取支付方式适配器
 * @param {String} type 支付方式
 * @returns {Object} 支付适配器实例
 */
export function getAdapterByType(type) {
  const AdapterClass = adapters[type.toLowerCase()];
  if (!AdapterClass) {
    return null;
  }
  
  // 延迟初始化，按需创建适配器实例
  if (typeof AdapterClass === 'function') {
    return new AdapterClass();
  }
  
  return AdapterClass;
}

// 导出所有适配器类
export {
  WechatAdapter,
  AlipayAdapter,
  VirtualAdapter,
  UnionpayAdapter
}; 